package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.UserBean;
import com.lwj.liwanjia.impl.UserView;
import com.lwj.liwanjia.model.UserModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/25.
 */

public class UserPresenter {
    private UserModel userModel;
    private UserView userView;

    public UserPresenter(UserView userView) {
        this.userView = userView;
        userModel = new UserModel();
    }

    public void getUserState(String name) {
        if (userView != null) {
            userModel.getUserState(name, new Subscriber<UserBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    userView.showError((Exception) e);
                }

                @Override
                public void onNext(UserBean userBean) {
                    userView.getUserState(userBean);
                }
            });
        }
    }
}
